package com.dwxt.community.admin.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.StatusCode;
import com.dwxt.community.admin.service.BroadcastHotService;
import com.dwxt.community.entity.dto.BroadcastColumnDto;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 广播 后台管理
 *
 * @author shenwenkang
 */
@RestController
@RequestMapping("/cms/admin/broadcastHot")
public class BroadcastHotControllerAdmin {

    @Autowired
    private BroadcastHotService broadcastHotService;


    /**
     * showdoc
     *
     * @return
     * @catalog 社区后台管理/直播
     * @title 获取热门视频
     * @method get
     * @description 栏目列表  or 搜索
     * @url /cms/admin/broadcastHot/get
     */
    @GetMapping("/get")
    public BaseResult get(@RequestParam(defaultValue = "1") Integer pageNum,
                          @RequestParam(defaultValue = "10") Integer pageSize) {
        return broadcastHotService.get(pageNum, pageSize);
    }

    /**
     * showdoc
     *
     * @return
     * @catalog 社区后台管理/直播
     * @title 获取视频列表
     * @method get
     * @description 获取视频列表
     * @url /cms/admin/broadcastHot/broadcastList
     */
    @GetMapping("/notBroadcastHotList")
    public BaseResult broadcastList(@RequestParam(defaultValue = "1") Integer pageNum,
                                    @RequestParam(defaultValue = "10") Integer pageSize) {
        return broadcastHotService.notBroadcastHotList(pageNum, pageSize);
    }

    /**
     * showdoc
     *
     * @param id 必须 Integer 栏目ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 社区后台管理/直播
     * @title 添加栏目
     * @method: post
     * @description 添加热门视频
     * @url /cms/admin/broadcastHot/insert
     */
    @PostMapping("/insert")
    public BaseResult get(String id) {
        if (StringUtils.isBlank(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastHotService.insert(id);
    }

    /**
     * showdoc
     *
     * @param broadcastId 必须 String 视频ID
     * @param sort        必须 Integer 位置ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 社区后台管理/直播
     * @title 修改栏目
     * @method post
     * @description 修改栏目
     * @url /cms/admin/broadcastHot/convertor
     */
    @PostMapping("/convertor")
    public BaseResult convertor(Integer id, String type) {
        if (StringUtils.isBlank(type) || ObjectUtils.isEmpty(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastHotService.convertor(id, type);
    }

    /**
     * showdoc
     *
     * @param id 必须 String 栏目ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     * @catalog 社区后台管理/直播
     * @title 删除热门视频
     * @method delete
     * @description 修改栏目
     * @url /cms/admin/broadcastHot/del
     */
    @DeleteMapping("/del")
    public BaseResult del(Integer id) {
        if (ObjectUtils.isEmpty(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastHotService.del(id);
    }
}
